package com.example.javasample;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.apache.commons.lang3.StringUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

/**
 * JavaSampleApplication
 *
 * @author Kylin
 */
@SpringBootApplication
@OpenAPIDefinition(
        info = @Info(
                title = "JavaSample API 文档",
                description = "这是使用 Knife4j 生成的 JavaSample API 文档",
                version = "1.0"
        )
)
//@MapperScan(basePackages = "com.example.javasample.mapper", annotationClass = Mapper.class)
@MapperScan("com.example.javasample.mapper")
public class JavaSampleApplication {

    public static void main(String[] args) {
//        SpringApplication.run(JavaSampleApplication.class, args);
        ApplicationContext context = SpringApplication.run(JavaSampleApplication.class, args);
        String port = context.getEnvironment().getProperty("server.port");
        String address = context.getEnvironment().getProperty("server.address");
        address = StringUtils.isNotBlank(address) ? address : "localhost";
        System.out.println("http://" + address + ":" + port);
        System.out.println("http://" + address + ":" + port + "/swagger-ui/index.html");
        System.out.println("http://" + address + ":" + port + "/doc.html");
    }

}
